package freshmanspecial.mredrock.com.welcomefreshman.Fragment;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import java.util.ArrayList;

import freshmanspecial.mredrock.com.welcomefreshman.Adapter.StrategyRecyclerAdapter;
import freshmanspecial.mredrock.com.welcomefreshman.Base.BaseFragment;
import freshmanspecial.mredrock.com.welcomefreshman.Bean.SchoolBuildingsBean;
import freshmanspecial.mredrock.com.welcomefreshman.Model.StrategyModel;
import freshmanspecial.mredrock.com.welcomefreshman.R;
import freshmanspecial.mredrock.com.welcomefreshman.Util.SpacesItemDecoration;

/**
 * Created by HP on 2017/8/6.
 */

public class StrategyFragment extends BaseFragment {
    private RecyclerView mRecyclerView;
    private StrategyRecyclerAdapter adapter;
    private  ArrayList<String> titleList,contentList,imageList;
    private  int type,ScooldBulding=1,Canting=3,Qinshi=2;
    public  StrategyFragment(int type){
this.type = type;
    }



    @Override
    protected void addDefaultData() {
        initView();
    }

    protected void addData() {

    }

    @Override
    protected void initView() {
        titleList = new ArrayList<>();
        imageList = new ArrayList<>();
        contentList = new ArrayList<>();
        int spacingInPixels = 8;

        mRecyclerView = $(R.id.recyclerview);
        mRecyclerView.addItemDecoration(new SpacesItemDecoration(spacingInPixels));
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        StrategyModel strategyModel = new StrategyModel();
        if(type ==Canting){
            strategyModel.getCanteen(new StrategyModel.OnGetData() {
                @Override
                public void onFinish(Object dataBean) {
                    mRecyclerView.setAdapter(adapter = new StrategyRecyclerAdapter(getContext(),dataBean,3));
                }
            });
        }
        if(type ==ScooldBulding){
            strategyModel.getSchoolBuildings(new StrategyModel.OnGetData() {
                @Override
                public void onFinish(Object dataBean) {
                    mRecyclerView.setAdapter(adapter = new StrategyRecyclerAdapter(getContext(),dataBean,type));
                }
            });
        }
        if(type ==Qinshi){
            strategyModel.getDormitory(new StrategyModel.OnGetData() {
                @Override
                public void onFinish(Object dataBean) {
                    mRecyclerView.setAdapter(adapter = new StrategyRecyclerAdapter(getContext(),dataBean,type));
                }
            });
        }




        Log.d("调用了","RecyclerView");
    }

    @Override
    protected int getResourceId() {
        return R.layout.special_2017_strategy_fragment;
    }
}
